<{include file="top.html" }>
</head>
<body>
    <{include file="wap_index_top.html" }>
	<div class="home_box" >
    <div class="flicking_con" style="position: inherit;">
        <div class="flicking_inner">
            <{foreach from=$marquee key=key item=item}>
            <a href="<{u('marqueJump?id='|cat:$item.id)}>"><{$key}></a>
            <{/foreach}>
        </div>
    </div>
    <div class="main_image">
        <ul>
            <{foreach from=$marquee item=item}>
            <li><a href="<{u('marqueJump?id='|cat:$item.id)}>"><img src="<{$preUploadUrl}><{$item.pic}>"></a></li>
            <{/foreach}>
        </ul>
        <a href="javascript:;" id="btn_prev"></a>
        <a href="javascript:;" id="btn_next"></a>
        </div>
    </div>

    <div class="nav-box">
        <ul class="nav-con">
            <{foreach from=$channels item=item key=id}>
                <li class="nav-list"><a href="javascript:loadArticle(<{$id}>)"><{$item}></a></li>
            <{/foreach}>
            <li class="slider"></li>
        </ul>
    </div>
    <ul class="home-list" id="articleList">
    </ul>
    <!-- 签到弹框 -->
    <{include file="signBody.html"}>

    <{* 投稿 <a href="<{u('User/contribute')}>" class="black pen"></a> *}>
    <{include file="footer.html" }>


</body>
</html>
<script src="<{$preStaticUrl}>Wap/js/flexible.js?v=<{$resVersion}>"></script>
<script type="text/javascript" src="<{$preStaticUrl}>js/jquery-2.1.4.min.js?v=<{$resVersion}>"></script>
<script type="text/javascript" src="<{$preStaticUrl}>Wap/js/jquery.touchSlider.js?v=<{$resVersion}>"></script>
<script type="text/javascript" src="<{$preStaticUrl}>Wap/js/nav.js?v=<{$resVersion}>"></script>
<script type="text/javascript" src="<{$preStaticUrl}>Wap/js/wapuse.js?v=<{$resVersion}>"></script>
<script type="text/javascript">
    fixUserHead();
    var channel=1;
    var page=1;
    function loadArticle(channelID){
        channel=channelID;
        page=1;
        flagAjax = true;
        $('#articleList').empty();
        load_more({p:page,c:channel});
    }

$(document).ready(function () {
    loadArticle(1);
	$(".main_visual").hover(function(){
		$("#btn_prev,#btn_next").fadeIn()
		},function(){
		$("#btn_prev,#btn_next").fadeOut()
		})
	$dragBln = false;
	$(".main_image").touchSlider({
		flexible : true,
		speed : 200,
		btn_prev : $("#btn_prev"),
		btn_next : $("#btn_next"),
		paging : $(".flicking_con a"),
		counter : function (e) {
			$(".flicking_con a").removeClass("on").eq(e.current-1).addClass("on");
		}
	});
	$(".main_image").bind("mousedown", function() {
		$dragBln = false;
	})
	$(".main_image").bind("dragstart", function() {
		$dragBln = true;
	})
	$(".main_image a").click(function() {
		if($dragBln) {
			return false;
		}
	})
	timer = setInterval(function() { $("#btn_next").click();}, 5000);
	$(".main_visual").hover(function() {
		clearInterval(timer);
	}, function() {
		timer = setInterval(function() { $("#btn_next").click();}, 5000);
	})
	$(".main_image").bind("touchstart", function() {
		clearInterval(timer);
	}).bind("touchend", function() {
		timer = setInterval(function() { $("#btn_next").click();}, 5000);
	});
//    //需要弹出提示时调用该方法即可
//    var firstTime = "<{$firstTime}>";
//    var addPoint = "<{$signInfo['point']}>";
//
//    if(firstTime == 1){
//        $(".PastBoxBlack").css('display','block');
//        $("#fadeIn").fadeIn(2000);
//        layer.msg("登陆成功，积分+"+addPoint,{shift:5,offset:$(window).height() * 0.8});
//    }

});
//    $('.close').click(function(){
//        $('.PastBoxBlack').css('display','none');
//
//    });
    $(function () {
        setTimeout(function () {
            if($(".main_image li:eq(0) img").height() != '0'){
                $(".main_image").css({'height':$(".main_image li:eq(0) img").height()+'px'});
                console.log($(".xy-panel-top").length);
                if($(".xy-panel-top").length>0) $(".flicking_inner").css({'top': parseInt($(".main_image li:eq(0) img").height())+35+'px'});
                else $(".flicking_inner").css({'top': parseInt($(".main_image li:eq(0) img").height())-15+'px'});
            }
        },1);
    });


    //拖动加载
    var flagData = true;
    var flagAjax = true;
    //加载
    function load_more(postData){
        if(! flagAjax){
            return false;
        }
        flagAjax = false;
        loadObj = layer.load(2);
        $.post("<{u('Article/articleMore')}>",postData , function(data){
            layer.close(loadObj);

            if (data.status != 0) {
                layer.msg("数据获取失败，请稍后重试或联系管理员解决！");
            } else {
                ++page;
                $("#articleList").append(data.dataHTML);
                fixUserHead();
                if (data.isPage==0) {
                    $("#load_container").empty();//.html('<a href="javascript:;" id="load_more"><span>没有更多了</span></a>');
                }else{
                    flagAjax = true;
                }
            }

        },'json');
    }

    var tmp_scroll = 0;
    //拖动加载
    function scroll_load(postData){
        if (tmp_scroll == $(window).height() + $(window).scrollTop()) {
            return;
        }
        tmp_scroll = $(window).height() + $(window).scrollTop();
        var jia_scroll = $(document).height() - ($(window).height() + $(window).scrollTop());
        if (jia_scroll < 100 && flagData) {
            load_more(postData);
        }
    }

    $(window).scroll(function(){
        scroll_load({p:page,c:channel});
    });

</script>
